import pandas as pd
import numpy as np
import plotly.offline as pyo
import plotly.graph_objects as go
import plotly.express as px
import matplotlib.pyplot as plt
pyo.init_notebook_mode()
confirmed_cases = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv"
death_cases = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv"
recovery_cases = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv"
country_cases = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/web-data/data/cases_country.csv"
country_cumulative = "https://covid19.who.int/WHO-COVID-19-global-table-data.csv"
confirmed_df = pd.read_csv(confirmed_cases)
print(confirmed_df.shape)
deaths_df = pd.read_csv(death_cases)
print(deaths_df.shape)
recovery_df = pd.read_csv(recovery_cases)
print(recovery_df.shape)
cases_country_df = pd.read_csv(country_cases)
print(cases_country_df.shape)
country_cumulative_df = pd.read_csv(country_cumulative)
print(country_cumulative_df.shape)
(275, 479) (275, 479) (260, 479) (192, 14) (238, 13)
confirmed_df.head()
| Province/State | Country/Region | Lat | Long | 1/22/20 | 1/23/20 | 1/24/20 | 1/25/20 | 1/26/20 | 1/27/20 | ... | 5/1/21 | 5/2/21 | 5/3/21 | 5/4/21 | 5/5/21 | 5/6/21 | 5/7/21 | 5/8/21 | 5/9/21 | 5/10/21 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | NaN | Afghanistan | 33.93911 | 67.709953 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 59939 | 60122 | 60300 | 60563 | 60797 | 61162 | 61455 | 61755 | 61842 | 62063 |
| 1 | NaN | Albania | 41.15330 | 20.168300 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 131185 | 131238 | 131276 | 131327 | 131419 | 131510 | 131577 | 131666 | 131723 | 131753 |
| 2 | NaN | Algeria | 28.03390 | 1.659600 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 122311 | 122522 | 122717 | 122999 | 123272 | 123473 | 123692 | 123900 | 124104 | 124288 |
| 3 | NaN | Andorra | 42.50630 | 1.521800 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 13232 | 13282 | 13295 | 13316 | 13340 | 13363 | 13390 | 13406 | 13423 | 13429 |
| 4 | NaN | Angola | -11.20270 | 17.873900 | 0 | 0 | 0 | 0 | 0 | 0 | ... | 26815 | 26993 | 27133 | 27284 | 27529 | 27921 | 28201 | 28477 | 28740 | 28875 |
5 rows × 479 columns
cases_country_df.columns
Index(['Country_Region', 'Last_Update', 'Lat', 'Long_', 'Confirmed', 'Deaths',
'Recovered', 'Active', 'Incident_Rate', 'People_Tested',
'People_Hospitalized', 'Mortality_Rate', 'UID', 'ISO3'],
dtype='object')
confirmed_df['Country/Region'].nunique()
192
confirmed_df = confirmed_df.replace(np.nan, '', regex=True)
deaths_df = deaths_df.replace(np.nan, '', regex=True)
recovery_df = recovery_df.replace(np.nan, '', regex=True)
cases_country_df = cases_country_df.replace(np.nan, '', regex=True)
country_cumulative_df = country_cumulative_df.replace(np.nan, '', regex=True)
global_data = cases_country_df.copy().drop(['Lat','Long_','Country_Region','Last_Update','Mortality_Rate','UID','ISO3','People_Tested','People_Hospitalized'], axis = 1)
global_summary = pd.DataFrame(global_data.sum()).transpose()
global_summary
| Confirmed | Deaths | |
|---|---|---|
| 0 | 158969512.0 | 3304132.0 |
confirmed_ts = confirmed_df.copy().drop(['Lat','Long','Country/Region','Province/State'],axis=1)
confirmed_ts_summary = confirmed_ts.sum()
confirmed_ts_summary
1/22/20 557
1/23/20 655
1/24/20 941
1/25/20 1433
1/26/20 2118
...
5/6/21 156070356
5/7/21 156901680
5/8/21 157688226
5/9/21 158326318
5/10/21 158951027
Length: 475, dtype: int64
fig1 = go.Figure(data=go.Scatter(x=confirmed_ts_summary.index, y = confirmed_ts_summary.values, mode='lines+markers'))
fig1.update_layout(title='Total CoronaVirus Confirmed Cases (Globally)', yaxis_title='Confirmed Cases', xaxis_tickangle=315)
fig1.show()
color_arr = px.colors.qualitative.Dark24
def draw_plot(ts_array, ts_label, title, colors, mode_size, line_size, x_axis_title, y_axis_title, tickangle=0, y_axis_type='', additional_annotations = []):
fig = go.Figure()
for index, ts in enumerate(ts_array):
fig.add_trace(go.Scatter(x=ts.index,
y=ts.values,
name=ts_label[index],
line=dict(color=colors[index], width=line_size[index]),connectgaps=True))
x_axis_dict = dict(showline=True,
showgrid=True,
showticklabels=True,
linecolor='rgb(204,204,204)',
linewidth=2,
ticks='outside',
tickfont=dict(family='Arial',size=12,color='rgb(82,82,82)'))
if x_axis_title:
x_axis_dict['title'] = x_axis_title
if tickangle > 0:
x_axis_dict['tickangle'] = tickangle
y_axis_dict = dict(showline=True,
showgrid=True,
showticklabels=True,
linecolor='rgb(204,204,204)',
linewidth=2,)
if y_axis_type := "":
y_axis_dict['type'] = y_axis_type
if y_axis_title:
y_axis_dict['title'] = y_axis_title
fig.update_layout(xaxis=x_axis_dict,
yaxis=y_axis_dict,
autosize=True,
margin=dict(autoexpand=True,l=100,r=20,t=110,),
showlegend=True
)
annotations = []
annotations.append(dict(xref='paper',yref='paper',x=0.0,y=1.05,xanchor='left',yanchor='bottom',
text = title,
font = dict(family='Arial',size=16,color='rgb(37,37,37)'),showarrow=False))
if(len(additional_annotations) > 0):
annotations.append(additional_annotations)
fig.update_layout(annotations=annotations)
return fig
confirmed_agg_ts = confirmed_df.copy().drop(['Lat','Long','Country/Region','Province/State'],axis=1).sum()
death_agg_ts = deaths_df.copy().drop(['Lat','Long','Country/Region','Province/State'],axis=1).sum()
recovered_agg_ts = recovery_df.copy().drop(['Lat','Long','Country/Region','Province/State'],axis=1).sum()
active_agg_ts = pd.Series(
data=np.array([x1-x2-x3 for (x1,x2,x3) in zip(confirmed_agg_ts.values,death_agg_ts.values,recovered_agg_ts.values)]),
index=confirmed_agg_ts.index)
ts_array = [confirmed_agg_ts, active_agg_ts, recovered_agg_ts, death_agg_ts]
labels = ['Confirmed', 'Active', 'Recovered', 'Deaths']
colors = [color_arr[5], color_arr[0], color_arr[2], color_arr[3]]
mode_size = [8,8,12,8]
line_size = [2,2,4,2]
fig2 = draw_plot(ts_array = ts_array,
ts_label = labels,
title = 'Covid-19 Case Status',
colors = colors, mode_size = mode_size,
line_size = line_size,
x_axis_title = "Date",
y_axis_title = "Case Count",
tickangle = 315,
y_axis_type = '', additional_annotations = [])
fig2.show()
cases_country_df.copy().drop(
['Lat','Long_','Last_Update','People_Tested','People_Hospitalized','UID', 'ISO3'],axis=1).sort_values(
'Confirmed',ascending=False).reset_index(drop=True).style.bar(align="left",width=98,color='#d65f5f')
| Country_Region | Confirmed | Deaths | Recovered | Active | Incident_Rate | Mortality_Rate | |
|---|---|---|---|---|---|---|---|
| 0 | US | 32744100.000000 | 582153.000000 | 9938.528368 | 1.777887 | ||
| 1 | India | 22992517.000000 | 249992.000000 | 19027304.000000 | 3715221.000000 | 1666.119126 | 1.087275 |
| 2 | Brazil | 15209990.000000 | 423229.000000 | 13481062.000000 | 1305699.000000 | 7155.641838 | 2.782573 |
| 3 | France | 5841593.000000 | 106845.000000 | 372400.000000 | 5362348.000000 | 8949.408146 | 1.829039 |
| 4 | Turkey | 5044936.000000 | 43311.000000 | 4743871.000000 | 257754.000000 | 5981.730863 | 0.858504 |
| 5 | Russia | 4832959.000000 | 111740.000000 | 4451443.000000 | 269776.000000 | 3311.732541 | 2.312041 |
| 6 | United Kingdom | 4452966.000000 | 127870.000000 | 15128.000000 | 4309968.000000 | 6559.475794 | 2.871569 |
| 7 | Italy | 4116287.000000 | 123031.000000 | 3619586.000000 | 373670.000000 | 6808.075667 | 2.988883 |
| 8 | Spain | 3581392.000000 | 78895.000000 | 150376.000000 | 3352121.000000 | 7659.947860 | 2.202914 |
| 9 | Germany | 3539590.000000 | 85120.000000 | 3207460.000000 | 247010.000000 | 4224.663806 | 2.404798 |
| 10 | Argentina | 3165121.000000 | 67821.000000 | 2837058.000000 | 260242.000000 | 7003.134386 | 2.142762 |
| 11 | Colombia | 3015301.000000 | 78342.000000 | 2835554.000000 | 101405.000000 | 5925.963237 | 2.598149 |
| 12 | Poland | 2835083.000000 | 70034.000000 | 2576034.000000 | 189015.000000 | 7490.983669 | 2.470263 |
| 13 | Iran | 2673219.000000 | 75261.000000 | 2127192.000000 | 470766.000000 | 3182.670575 | 2.815370 |
| 14 | Mexico | 2366496.000000 | 219089.000000 | 1888638.000000 | 258769.000000 | 1851.830086 | 9.257949 |
| 15 | Ukraine | 2180429.000000 | 48544.000000 | 1828877.000000 | 303008.000000 | 4985.688516 | 2.226351 |
| 16 | Peru | 1850290.000000 | 64103.000000 | 1798844.000000 | -12657.000000 | 5611.727047 | 3.464484 |
| 17 | Indonesia | 1718575.000000 | 47218.000000 | 1574615.000000 | 96742.000000 | 628.309538 | 2.747509 |
| 18 | Czechia | 1646981.000000 | 29749.000000 | 1583590.000000 | 33642.000000 | 15379.435692 | 1.806275 |
| 19 | South Africa | 1597724.000000 | 54825.000000 | 1517350.000000 | 25549.000000 | 2693.912140 | 3.431444 |
| 20 | Netherlands | 1592742.000000 | 17602.000000 | 26310.000000 | 1548830.000000 | 9295.324220 | 1.105138 |
| 21 | Canada | 1302489.000000 | 24660.000000 | 1201850.000000 | 75979.000000 | 3440.667934 | 1.893298 |
| 22 | Chile | 1252808.000000 | 27318.000000 | 1188831.000000 | 36659.000000 | 6553.642514 | 2.180542 |
| 23 | Iraq | 1117627.000000 | 15800.000000 | 1011606.000000 | 90221.000000 | 2778.611266 | 1.413710 |
| 24 | Philippines | 1108826.000000 | 18562.000000 | 1030367.000000 | 59897.000000 | 1011.877187 | 1.674023 |
| 25 | Romania | 1066731.000000 | 29034.000000 | 1015092.000000 | 22605.000000 | 5545.007969 | 2.721773 |
| 26 | Belgium | 1017876.000000 | 24583.000000 | 993293.000000 | 8782.655094 | 2.415127 | |
| 27 | Sweden | 1007792.000000 | 14173.000000 | 993619.000000 | 9978.859858 | 1.406342 | |
| 28 | Pakistan | 864557.000000 | 19106.000000 | 766492.000000 | 78959.000000 | 391.392945 | 2.209918 |
| 29 | Portugal | 839740.000000 | 16993.000000 | 800645.000000 | 22102.000000 | 8235.403842 | 2.023603 |
| 30 | Israel | 838993.000000 | 6378.000000 | 831641.000000 | 974.000000 | 9693.131833 | 0.760197 |
| 31 | Hungary | 792879.000000 | 28792.000000 | 583802.000000 | 180285.000000 | 8207.559768 | 3.631323 |
| 32 | Bangladesh | 775027.000000 | 11972.000000 | 712277.000000 | 50778.000000 | 470.599249 | 1.544720 |
| 33 | Jordan | 720998.000000 | 9125.000000 | 705392.000000 | 6481.000000 | 7066.432490 | 1.265607 |
| 34 | Serbia | 701326.000000 | 6576.000000 | 694750.000000 | 8026.740312 | 0.937652 | |
| 35 | Switzerland | 674296.000000 | 10716.000000 | 317600.000000 | 345980.000000 | 7791.169986 | 1.589213 |
| 36 | Japan | 650256.000000 | 10962.000000 | 559397.000000 | 79897.000000 | 514.132045 | 1.685798 |
| 37 | Austria | 631896.000000 | 10392.000000 | 605441.000000 | 16063.000000 | 7016.077456 | 1.644574 |
| 38 | United Arab Emirates | 537524.000000 | 1615.000000 | 517805.000000 | 18104.000000 | 5434.805468 | 0.300452 |
| 39 | Lebanon | 533141.000000 | 7507.000000 | 487126.000000 | 38508.000000 | 7811.083883 | 1.408070 |
| 40 | Morocco | 513922.000000 | 9077.000000 | 501146.000000 | 3699.000000 | 1392.344163 | 1.766221 |
| 41 | Malaysia | 444484.000000 | 1700.000000 | 405388.000000 | 37396.000000 | 1373.305405 | 0.382466 |
| 42 | Saudi Arabia | 427370.000000 | 7085.000000 | 410816.000000 | 9469.000000 | 1227.585548 | 1.657814 |
| 43 | Bulgaria | 411280.000000 | 17045.000000 | 351397.000000 | 42838.000000 | 5919.022170 | 4.144379 |
| 44 | Nepal | 403794.000000 | 3859.000000 | 306794.000000 | 93141.000000 | 1385.855307 | 0.955685 |
| 45 | Ecuador | 402060.000000 | 19242.000000 | 342878.000000 | 39940.000000 | 2278.856389 | 4.785853 |
| 46 | Kazakhstan | 400068.000000 | 3377.000000 | 354189.000000 | 42502.000000 | 2130.661143 | 0.844107 |
| 47 | Slovakia | 385786.000000 | 12051.000000 | 255300.000000 | 118435.000000 | 7066.139673 | 3.123753 |
| 48 | Belarus | 369767.000000 | 2642.000000 | 360255.000000 | 6870.000000 | 3913.159475 | 0.714504 |
| 49 | Panama | 367908.000000 | 6277.000000 | 357353.000000 | 4278.000000 | 8526.715689 | 1.706133 |
| 50 | Greece | 363904.000000 | 11089.000000 | 93764.000000 | 259051.000000 | 3491.336898 | 3.047232 |
| 51 | Croatia | 344747.000000 | 7503.000000 | 328993.000000 | 8251.000000 | 8397.673428 | 2.176379 |
| 52 | Azerbaijan | 327087.000000 | 4698.000000 | 307011.000000 | 15378.000000 | 3225.972527 | 1.436315 |
| 53 | Georgia | 324256.000000 | 4336.000000 | 303679.000000 | 16241.000000 | 8128.397476 | 1.337215 |
| 54 | Tunisia | 321837.000000 | 11468.000000 | 279634.000000 | 30735.000000 | 2723.135649 | 3.563294 |
| 55 | Bolivia | 318610.000000 | 13228.000000 | 261552.000000 | 43830.000000 | 2729.454369 | 4.151784 |
| 56 | West Bank and Gaza | 302249.000000 | 3378.000000 | 287206.000000 | 11665.000000 | 5924.805975 | 1.117622 |
| 57 | Paraguay | 299684.000000 | 7209.000000 | 248587.000000 | 43888.000000 | 4201.650747 | 2.405534 |
| 58 | Kuwait | 286046.000000 | 1652.000000 | 270883.000000 | 13511.000000 | 6698.086412 | 0.577529 |
| 59 | Dominican Republic | 272108.000000 | 3540.000000 | 231963.000000 | 36605.000000 | 2508.392405 | 1.300954 |
| 60 | Costa Rica | 271478.000000 | 3430.000000 | 214788.000000 | 53260.000000 | 5329.248619 | 1.263454 |
| 61 | Ethiopia | 263120.000000 | 3897.000000 | 211493.000000 | 47730.000000 | 228.872477 | 1.481073 |
| 62 | Denmark | 260687.000000 | 2498.000000 | 246862.000000 | 11327.000000 | 4500.653724 | 0.958237 |
| 63 | Lithuania | 259862.000000 | 4053.000000 | 234223.000000 | 21586.000000 | 9545.709845 | 1.559674 |
| 64 | Ireland | 253189.000000 | 4921.000000 | 23364.000000 | 224904.000000 | 5127.571086 | 1.943607 |
| 65 | Moldova | 252798.000000 | 5958.000000 | 243731.000000 | 3109.000000 | 6266.740672 | 2.356822 |
| 66 | Slovenia | 246231.000000 | 4299.000000 | 232983.000000 | 8949.000000 | 11844.110341 | 1.745922 |
| 67 | Egypt | 238560.000000 | 13972.000000 | 177440.000000 | 47148.000000 | 233.118084 | 5.856808 |
| 68 | Guatemala | 235304.000000 | 7736.000000 | 214601.000000 | 12967.000000 | 1313.405264 | 3.287662 |
| 69 | Uruguay | 222870.000000 | 3171.000000 | 194964.000000 | 24735.000000 | 6415.875514 | 1.422803 |
| 70 | Honduras | 220988.000000 | 5701.000000 | 81639.000000 | 133648.000000 | 2231.163515 | 2.579778 |
| 71 | Armenia | 219596.000000 | 4256.000000 | 205675.000000 | 9665.000000 | 7410.687107 | 1.938105 |
| 72 | Qatar | 211389.000000 | 512.000000 | 202552.000000 | 8325.000000 | 7337.195338 | 0.242207 |
| 73 | Venezuela | 209162.000000 | 2304.000000 | 192075.000000 | 14783.000000 | 735.554998 | 1.101539 |
| 74 | Oman | 202137.000000 | 2138.000000 | 185607.000000 | 14392.000000 | 3958.330967 | 1.057698 |
| 75 | Bosnia and Herzegovina | 201217.000000 | 8862.000000 | 166047.000000 | 26308.000000 | 6133.140698 | 4.404200 |
| 76 | Bahrain | 191018.000000 | 691.000000 | 176338.000000 | 13989.000000 | 11225.899648 | 0.361746 |
| 77 | Libya | 180226.000000 | 3072.000000 | 166680.000000 | 10474.000000 | 2622.885640 | 1.704527 |
| 78 | Nigeria | 165468.000000 | 2065.000000 | 156318.000000 | 7085.000000 | 80.269880 | 1.247975 |
| 79 | Kenya | 163620.000000 | 2907.000000 | 112298.000000 | 48415.000000 | 304.288719 | 1.776678 |
| 80 | North Macedonia | 154051.000000 | 5109.000000 | 138370.000000 | 10572.000000 | 7394.282368 | 3.316434 |
| 81 | Burma | 142963.000000 | 3210.000000 | 132045.000000 | 7708.000000 | 262.752327 | 2.245336 |
| 82 | Albania | 131753.000000 | 2416.000000 | 118041.000000 | 11296.000000 | 4578.254222 | 1.833734 |
| 83 | Sri Lanka | 128530.000000 | 827.000000 | 105611.000000 | 22092.000000 | 600.235835 | 0.643430 |
| 84 | Korea, South | 128283.000000 | 1879.000000 | 118717.000000 | 7687.000000 | 250.214637 | 1.464730 |
| 85 | Estonia | 125696.000000 | 1206.000000 | 116648.000000 | 7842.000000 | 9475.484701 | 0.959458 |
| 86 | Latvia | 124301.000000 | 2213.000000 | 113214.000000 | 8874.000000 | 6590.015279 | 1.780356 |
| 87 | Algeria | 124288.000000 | 3335.000000 | 86554.000000 | 34399.000000 | 283.432255 | 2.683284 |
| 88 | Cuba | 117097.000000 | 741.000000 | 110312.000000 | 6044.000000 | 1033.821576 | 0.632809 |
| 89 | Norway | 117022.000000 | 767.000000 | 17998.000000 | 98257.000000 | 2158.582849 | 0.655432 |
| 90 | Kosovo | 105784.000000 | 2207.000000 | 96841.000000 | 6736.000000 | 5843.238329 | 2.086327 |
| 91 | China | 102643.000000 | 4846.000000 | 97390.000000 | 407.000000 | 7.307235 | 4.721218 |
| 92 | Kyrgyzstan | 99033.000000 | 1667.000000 | 92120.000000 | 5246.000000 | 1517.935327 | 1.683277 |
| 93 | Montenegro | 98365.000000 | 1544.000000 | 95070.000000 | 1751.000000 | 15661.670345 | 1.569664 |
| 94 | Uzbekistan | 95072.000000 | 664.000000 | 90664.000000 | 3744.000000 | 284.058187 | 0.698418 |
| 95 | Ghana | 93011.000000 | 783.000000 | 90697.000000 | 1531.000000 | 299.331138 | 0.841836 |
| 96 | Zambia | 92112.000000 | 1257.000000 | 90501.000000 | 354.000000 | 501.045586 | 1.364643 |
| 97 | Finland | 88866.000000 | 922.000000 | 46000.000000 | 41944.000000 | 1603.871556 | 1.037517 |
| 98 | Thailand | 86924.000000 | 452.000000 | 26873.000000 | 59599.000000 | 124.532991 | 0.519994 |
| 99 | Cameroon | 74946.000000 | 1152.000000 | 35261.000000 | 38533.000000 | 282.326467 | 1.537107 |
| 100 | El Salvador | 70380.000000 | 2164.000000 | 65921.000000 | 2295.000000 | 1085.072757 | 3.074737 |
| 101 | Mozambique | 70283.000000 | 825.000000 | 67799.000000 | 1659.000000 | 224.866491 | 1.173826 |
| 102 | Cyprus | 69708.000000 | 337.000000 | 39061.000000 | 30310.000000 | 5773.583874 | 0.483445 |
| 103 | Luxembourg | 68431.000000 | 804.000000 | 65460.000000 | 2167.000000 | 10931.888763 | 1.174906 |
| 104 | Afghanistan | 62063.000000 | 2698.000000 | 54382.000000 | 4983.000000 | 159.428834 | 4.347196 |
| 105 | Singapore | 61378.000000 | 31.000000 | 60953.000000 | 394.000000 | 1049.135068 | 0.050507 |
| 106 | Namibia | 50209.000000 | 691.000000 | 47384.000000 | 2134.000000 | 1976.019672 | 1.376247 |
| 107 | Botswana | 49041.000000 | 751.000000 | 46290.000000 | 2000.000000 | 2085.409026 | 1.531372 |
| 108 | Jamaica | 46782.000000 | 809.000000 | 22395.000000 | 23578.000000 | 1579.853308 | 1.729298 |
| 109 | Cote d'Ivoire | 46443.000000 | 291.000000 | 45874.000000 | 278.000000 | 176.065342 | 0.626575 |
| 110 | Mongolia | 45936.000000 | 179.000000 | 34230.000000 | 11527.000000 | 1401.217463 | 0.389673 |
| 111 | Uganda | 42384.000000 | 346.000000 | 41971.000000 | 67.000000 | 92.660851 | 0.816346 |
| 112 | Senegal | 40714.000000 | 1120.000000 | 39410.000000 | 184.000000 | 243.156774 | 2.750896 |
| 113 | Madagascar | 39162.000000 | 729.000000 | 36255.000000 | 2178.000000 | 141.424915 | 1.861498 |
| 114 | Zimbabwe | 38433.000000 | 1576.000000 | 36208.000000 | 649.000000 | 258.582983 | 4.100643 |
| 115 | Maldives | 37019.000000 | 87.000000 | 26547.000000 | 10385.000000 | 6848.496509 | 0.235014 |
| 116 | Sudan | 34889.000000 | 2446.000000 | 27949.000000 | 4494.000000 | 79.565751 | 7.010806 |
| 117 | Malawi | 34180.000000 | 1153.000000 | 32164.000000 | 863.000000 | 178.672663 | 3.373318 |
| 118 | Malta | 30458.000000 | 417.000000 | 29828.000000 | 213.000000 | 6898.144898 | 1.369098 |
| 119 | Congo (Kinshasa) | 30350.000000 | 772.000000 | 26434.000000 | 3144.000000 | 33.887365 | 2.543657 |
| 120 | Australia | 29938.000000 | 910.000000 | 23460.000000 | 5568.000000 | 117.589760 | 3.039615 |
| 121 | Angola | 28875.000000 | 636.000000 | 24772.000000 | 3467.000000 | 87.856035 | 2.202597 |
| 122 | Cabo Verde | 26578.000000 | 235.000000 | 23402.000000 | 2941.000000 | 4780.319000 | 0.884190 |
| 123 | Rwanda | 25714.000000 | 338.000000 | 24155.000000 | 1221.000000 | 198.529842 | 1.314459 |
| 124 | Gabon | 23565.000000 | 143.000000 | 20051.000000 | 3371.000000 | 1058.754709 | 0.606832 |
| 125 | Syria | 23439.000000 | 1664.000000 | 19024.000000 | 2751.000000 | 133.932115 | 7.099279 |
| 126 | Guinea | 22633.000000 | 150.000000 | 20231.000000 | 2252.000000 | 172.339591 | 0.662749 |
| 127 | Cambodia | 20223.000000 | 131.000000 | 8170.000000 | 11922.000000 | 120.958401 | 0.647777 |
| 128 | Mauritania | 18691.000000 | 456.000000 | 17918.000000 | 317.000000 | 401.986382 | 2.439677 |
| 129 | Eswatini | 18482.000000 | 671.000000 | 17784.000000 | 27.000000 | 1593.050638 | 3.630559 |
| 130 | Guyana | 14442.000000 | 327.000000 | 12267.000000 | 1848.000000 | 1836.098754 | 2.264229 |
| 131 | Somalia | 14415.000000 | 747.000000 | 6191.000000 | 7477.000000 | 90.699059 | 5.182102 |
| 132 | Mali | 14115.000000 | 502.000000 | 9039.000000 | 4574.000000 | 69.700833 | 3.556500 |
| 133 | Trinidad and Tobago | 13454.000000 | 215.000000 | 9381.000000 | 3858.000000 | 961.349519 | 1.598038 |
| 134 | Andorra | 13429.000000 | 127.000000 | 13021.000000 | 281.000000 | 17380.443927 | 0.945714 |
| 135 | Burkina Faso | 13382.000000 | 162.000000 | 13164.000000 | 56.000000 | 64.018667 | 1.210581 |
| 136 | Tajikistan | 13308.000000 | 90.000000 | 13218.000000 | 0.000000 | 139.531343 | 0.676285 |
| 137 | Togo | 13167.000000 | 125.000000 | 11694.000000 | 1348.000000 | 159.045999 | 0.949343 |
| 138 | Haiti | 13164.000000 | 263.000000 | 12304.000000 | 597.000000 | 115.448032 | 1.997873 |
| 139 | Belize | 12700.000000 | 323.000000 | 12303.000000 | 74.000000 | 3193.996293 | 2.543307 |
| 140 | Papua New Guinea | 12086.000000 | 121.000000 | 10599.000000 | 1366.000000 | 135.083978 | 1.001158 |
| 141 | Djibouti | 11355.000000 | 149.000000 | 11132.000000 | 74.000000 | 1149.289171 | 1.312197 |
| 142 | Congo (Brazzaville) | 11343.000000 | 148.000000 | 8208.000000 | 2987.000000 | 205.560183 | 1.304769 |
| 143 | Suriname | 11213.000000 | 218.000000 | 9831.000000 | 1164.000000 | 1911.413249 | 1.944172 |
| 144 | Bahamas | 10908.000000 | 214.000000 | 9854.000000 | 840.000000 | 2773.822117 | 1.961863 |
| 145 | Lesotho | 10773.000000 | 319.000000 | 6427.000000 | 4027.000000 | 502.882014 | 2.961106 |
| 146 | South Sudan | 10641.000000 | 115.000000 | 10462.000000 | 64.000000 | 95.062155 | 1.080725 |
| 147 | Seychelles | 8172.000000 | 28.000000 | 5658.000000 | 2486.000000 | 8309.945088 | 0.342633 |
| 148 | Benin | 7884.000000 | 100.000000 | 7652.000000 | 132.000000 | 65.032345 | 1.268392 |
| 149 | Equatorial Guinea | 7694.000000 | 112.000000 | 7279.000000 | 303.000000 | 548.402157 | 1.455680 |
| 150 | Nicaragua | 6989.000000 | 183.000000 | 4225.000000 | 2581.000000 | 105.501442 | 2.618400 |
| 151 | Central African Republic | 6674.000000 | 93.000000 | 5112.000000 | 1469.000000 | 138.184806 | 1.393467 |
| 152 | Iceland | 6519.000000 | 29.000000 | 6390.000000 | 100.000000 | 1910.329670 | 0.444854 |
| 153 | Yemen | 6485.000000 | 1275.000000 | 3001.000000 | 2209.000000 | 21.742798 | 19.660756 |
| 154 | Gambia | 5929.000000 | 175.000000 | 5598.000000 | 156.000000 | 245.338202 | 2.951594 |
| 155 | Niger | 5322.000000 | 192.000000 | 4904.000000 | 226.000000 | 21.985707 | 3.607666 |
| 156 | San Marino | 5083.000000 | 90.000000 | 4968.000000 | 25.000000 | 14977.311568 | 1.770608 |
| 157 | Chad | 4882.000000 | 171.000000 | 4657.000000 | 54.000000 | 29.721429 | 3.502663 |
| 158 | Saint Lucia | 4690.000000 | 75.000000 | 4461.000000 | 154.000000 | 2554.062811 | 1.599147 |
| 159 | Burundi | 4200.000000 | 6.000000 | 773.000000 | 3421.000000 | 35.321481 | 0.142857 |
| 160 | Sierra Leone | 4089.000000 | 79.000000 | 3093.000000 | 917.000000 | 51.259969 | 1.932013 |
| 161 | Barbados | 3946.000000 | 45.000000 | 3861.000000 | 40.000000 | 1373.137860 | 1.140395 |
| 162 | Comoros | 3860.000000 | 146.000000 | 3688.000000 | 26.000000 | 443.884797 | 3.782383 |
| 163 | Eritrea | 3754.000000 | 12.000000 | 3613.000000 | 129.000000 | 105.853018 | 0.319659 |
| 164 | Guinea-Bissau | 3741.000000 | 67.000000 | 3400.000000 | 274.000000 | 190.091657 | 1.790965 |
| 165 | Vietnam | 3507.000000 | 35.000000 | 2618.000000 | 854.000000 | 3.602888 | 0.998004 |
| 166 | Timor-Leste | 3353.000000 | 5.000000 | 1683.000000 | 1665.000000 | 254.315321 | 0.149120 |
| 167 | Liechtenstein | 2974.000000 | 58.000000 | 2879.000000 | 37.000000 | 7798.201222 | 1.950235 |
| 168 | New Zealand | 2643.000000 | 26.000000 | 2591.000000 | 26.000000 | 54.808633 | 0.983731 |
| 169 | Monaco | 2481.000000 | 32.000000 | 2420.000000 | 29.000000 | 6321.985526 | 1.289802 |
| 170 | Sao Tome and Principe | 2318.000000 | 35.000000 | 2262.000000 | 21.000000 | 1057.669932 | 1.509922 |
| 171 | Liberia | 2114.000000 | 85.000000 | 1962.000000 | 67.000000 | 41.797845 | 4.020814 |
| 172 | Saint Vincent and the Grenadines | 1922.000000 | 12.000000 | 1741.000000 | 169.000000 | 1732.358694 | 0.624350 |
| 173 | Laos | 1327.000000 | 1.000000 | 238.000000 | 1088.000000 | 18.239156 | 0.075358 |
| 174 | Mauritius | 1256.000000 | 17.000000 | 1124.000000 | 115.000000 | 98.760229 | 1.353503 |
| 175 | Bhutan | 1241.000000 | 1.000000 | 1089.000000 | 151.000000 | 160.832128 | 0.080580 |
| 176 | Antigua and Barbuda | 1237.000000 | 32.000000 | 1170.000000 | 35.000000 | 1263.172943 | 2.586904 |
| 177 | Taiwan* | 1199.000000 | 12.000000 | 1089.000000 | 98.000000 | 5.034267 | 1.000834 |
| 178 | Diamond Princess | 712.000000 | 13.000000 | 699.000000 | 0.000000 | 1.825843 | |
| 179 | Tanzania | 509.000000 | 21.000000 | 183.000000 | 305.000000 | 0.852108 | 4.125737 |
| 180 | Brunei | 230.000000 | 3.000000 | 218.000000 | 9.000000 | 52.573471 | 1.304348 |
| 181 | Dominica | 175.000000 | 0.000000 | 175.000000 | 0.000000 | 243.085941 | 0.000000 |
| 182 | Grenada | 160.000000 | 1.000000 | 158.000000 | 1.000000 | 142.198207 | 0.625000 |
| 183 | Fiji | 152.000000 | 3.000000 | 101.000000 | 48.000000 | 16.955883 | 1.973684 |
| 184 | Saint Kitts and Nevis | 45.000000 | 0.000000 | 44.000000 | 1.000000 | 84.599188 | 0.000000 |
| 185 | Holy See | 27.000000 | 0.000000 | 15.000000 | 12.000000 | 3337.453646 | 0.000000 |
| 186 | Solomon Islands | 20.000000 | 0.000000 | 20.000000 | 0.000000 | 3.063453 | 0.000000 |
| 187 | MS Zaandam | 9.000000 | 2.000000 | 7.000000 | 0.000000 | 22.222222 | |
| 188 | Vanuatu | 4.000000 | 1.000000 | 3.000000 | 0.000000 | 1.366680 | 25.000000 |
| 189 | Marshall Islands | 4.000000 | 0.000000 | 4.000000 | 0.000000 | 6.847791 | 0.000000 |
| 190 | Samoa | 3.000000 | 0.000000 | 2.000000 | 1.000000 | 1.529598 | 0.000000 |
| 191 | Micronesia | 1.000000 | 0.000000 | 1.000000 | 0.000000 | 0.878619 | 0.000000 |
print(country_cumulative_df.columns)
Index(['Name', 'WHO Region', 'Cases - cumulative total',
'Cases - cumulative total per 100000 population',
'Cases - newly reported in last 7 days',
'Cases - newly reported in last 7 days per 100000 population',
'Cases - newly reported in last 24 hours', 'Deaths - cumulative total',
'Deaths - cumulative total per 100000 population',
'Deaths - newly reported in last 7 days',
'Deaths - newly reported in last 7 days per 100000 population',
'Deaths - newly reported in last 24 hours',
'Transmission Classification'],
dtype='object')
country_cumulative_df = country_cumulative_df.drop(['WHO Region','Cases - cumulative total per 100000 population','Cases - newly reported in last 7 days per 100000 population','Deaths - cumulative total per 100000 population','Deaths - newly reported in last 7 days','Deaths - newly reported in last 7 days per 100000 population','Transmission Classification'],axis=1)
country_cumulative_df = country_cumulative_df.set_index('Name')
country_cumulative_df['Recovered'] = country_cumulative_df['Cases - cumulative total'] - country_cumulative_df['Deaths - cumulative total']
country_cumulative_df = country_cumulative_df.drop(['Cases - cumulative total', 'Deaths - newly reported in last 24 hours'], axis=1)
print("Countries available in the Dataset")
country_cumulative_df.copy().drop(
['Cases - newly reported in last 7 days','Cases - newly reported in last 24 hours','Deaths - cumulative total','Recovered'],axis=1).sort_values('Name',ascending=True).reset_index(drop=False).style.bar(align="left",width=80)
Countries available in the Dataset
| Name | |
|---|---|
| 0 | Afghanistan |
| 1 | Albania |
| 2 | Algeria |
| 3 | American Samoa |
| 4 | Andorra |
| 5 | Angola |
| 6 | Anguilla |
| 7 | Antigua and Barbuda |
| 8 | Argentina |
| 9 | Armenia |
| 10 | Aruba |
| 11 | Australia |
| 12 | Austria |
| 13 | Azerbaijan |
| 14 | Bahamas |
| 15 | Bahrain |
| 16 | Bangladesh |
| 17 | Barbados |
| 18 | Belarus |
| 19 | Belgium |
| 20 | Belize |
| 21 | Benin |
| 22 | Bermuda |
| 23 | Bhutan |
| 24 | Bolivia (Plurinational State of) |
| 25 | Bonaire |
| 26 | Bosnia and Herzegovina |
| 27 | Botswana |
| 28 | Brazil |
| 29 | British Virgin Islands |
| 30 | Brunei Darussalam |
| 31 | Bulgaria |
| 32 | Burkina Faso |
| 33 | Burundi |
| 34 | Cabo Verde |
| 35 | Cambodia |
| 36 | Cameroon |
| 37 | Canada |
| 38 | Cayman Islands |
| 39 | Central African Republic |
| 40 | Chad |
| 41 | Chile |
| 42 | China |
| 43 | Colombia |
| 44 | Comoros |
| 45 | Congo |
| 46 | Cook Islands |
| 47 | Costa Rica |
| 48 | Croatia |
| 49 | Cuba |
| 50 | Curaçao |
| 51 | Cyprus |
| 52 | Czechia |
| 53 | Côte d’Ivoire |
| 54 | Democratic People's Republic of Korea |
| 55 | Democratic Republic of the Congo |
| 56 | Denmark |
| 57 | Djibouti |
| 58 | Dominica |
| 59 | Dominican Republic |
| 60 | Ecuador |
| 61 | Egypt |
| 62 | El Salvador |
| 63 | Equatorial Guinea |
| 64 | Eritrea |
| 65 | Estonia |
| 66 | Eswatini |
| 67 | Ethiopia |
| 68 | Falkland Islands (Malvinas) |
| 69 | Faroe Islands |
| 70 | Fiji |
| 71 | Finland |
| 72 | France |
| 73 | French Guiana |
| 74 | French Polynesia |
| 75 | Gabon |
| 76 | Gambia |
| 77 | Georgia |
| 78 | Germany |
| 79 | Ghana |
| 80 | Gibraltar |
| 81 | Global |
| 82 | Greece |
| 83 | Greenland |
| 84 | Grenada |
| 85 | Guadeloupe |
| 86 | Guam |
| 87 | Guatemala |
| 88 | Guernsey |
| 89 | Guinea |
| 90 | Guinea-Bissau |
| 91 | Guyana |
| 92 | Haiti |
| 93 | Holy See |
| 94 | Honduras |
| 95 | Hungary |
| 96 | Iceland |
| 97 | India |
| 98 | Indonesia |
| 99 | Iran (Islamic Republic of) |
| 100 | Iraq |
| 101 | Ireland |
| 102 | Isle of Man |
| 103 | Israel |
| 104 | Italy |
| 105 | Jamaica |
| 106 | Japan |
| 107 | Jersey |
| 108 | Jordan |
| 109 | Kazakhstan |
| 110 | Kenya |
| 111 | Kiribati |
| 112 | Kosovo[1] |
| 113 | Kuwait |
| 114 | Kyrgyzstan |
| 115 | Lao People's Democratic Republic |
| 116 | Latvia |
| 117 | Lebanon |
| 118 | Lesotho |
| 119 | Liberia |
| 120 | Libya |
| 121 | Liechtenstein |
| 122 | Lithuania |
| 123 | Luxembourg |
| 124 | Madagascar |
| 125 | Malawi |
| 126 | Malaysia |
| 127 | Maldives |
| 128 | Mali |
| 129 | Malta |
| 130 | Marshall Islands |
| 131 | Martinique |
| 132 | Mauritania |
| 133 | Mauritius |
| 134 | Mayotte |
| 135 | Mexico |
| 136 | Micronesia (Federated States of) |
| 137 | Monaco |
| 138 | Mongolia |
| 139 | Montenegro |
| 140 | Montserrat |
| 141 | Morocco |
| 142 | Mozambique |
| 143 | Myanmar |
| 144 | Namibia |
| 145 | Nauru |
| 146 | Nepal |
| 147 | Netherlands |
| 148 | New Caledonia |
| 149 | New Zealand |
| 150 | Nicaragua |
| 151 | Niger |
| 152 | Nigeria |
| 153 | Niue |
| 154 | North Macedonia |
| 155 | Northern Mariana Islands (Commonwealth of the) |
| 156 | Norway |
| 157 | Oman |
| 158 | Other |
| 159 | Pakistan |
| 160 | Palau |
| 161 | Panama |
| 162 | Papua New Guinea |
| 163 | Paraguay |
| 164 | Peru |
| 165 | Philippines |
| 166 | Pitcairn Islands |
| 167 | Poland |
| 168 | Portugal |
| 169 | Puerto Rico |
| 170 | Qatar |
| 171 | Republic of Korea |
| 172 | Republic of Moldova |
| 173 | Romania |
| 174 | Russian Federation |
| 175 | Rwanda |
| 176 | Réunion |
| 177 | Saba |
| 178 | Saint Barthélemy |
| 179 | Saint Helena |
| 180 | Saint Kitts and Nevis |
| 181 | Saint Lucia |
| 182 | Saint Martin |
| 183 | Saint Pierre and Miquelon |
| 184 | Saint Vincent and the Grenadines |
| 185 | Samoa |
| 186 | San Marino |
| 187 | Sao Tome and Principe |
| 188 | Saudi Arabia |
| 189 | Senegal |
| 190 | Serbia |
| 191 | Seychelles |
| 192 | Sierra Leone |
| 193 | Singapore |
| 194 | Sint Eustatius |
| 195 | Sint Maarten |
| 196 | Slovakia |
| 197 | Slovenia |
| 198 | Solomon Islands |
| 199 | Somalia |
| 200 | South Africa |
| 201 | South Sudan |
| 202 | Spain |
| 203 | Sri Lanka |
| 204 | Sudan |
| 205 | Suriname |
| 206 | Sweden |
| 207 | Switzerland |
| 208 | Syrian Arab Republic |
| 209 | Tajikistan |
| 210 | Thailand |
| 211 | The United Kingdom |
| 212 | Timor-Leste |
| 213 | Togo |
| 214 | Tokelau |
| 215 | Tonga |
| 216 | Trinidad and Tobago |
| 217 | Tunisia |
| 218 | Turkey |
| 219 | Turkmenistan |
| 220 | Turks and Caicos Islands |
| 221 | Tuvalu |
| 222 | Uganda |
| 223 | Ukraine |
| 224 | United Arab Emirates |
| 225 | United Republic of Tanzania |
| 226 | United States Virgin Islands |
| 227 | United States of America |
| 228 | Uruguay |
| 229 | Uzbekistan |
| 230 | Vanuatu |
| 231 | Venezuela (Bolivarian Republic of) |
| 232 | Viet Nam |
| 233 | Wallis and Futuna |
| 234 | Yemen |
| 235 | Zambia |
| 236 | Zimbabwe |
| 237 | occupied Palestinian territory, including east Jerusalem |
country = input("Enter country name : ").title()
is_country_exist = True
if 'Of' in country:
country = country.replace('Of','of')
try:
country_cumulative_df.loc[[country]]
except:
print("Sorry, country not found!")
is_country_exist = False
Enter country name : india
if(is_country_exist):
recovered = country_cumulative_df.at[country,'Recovered']
deaths = country_cumulative_df.at[country,'Deaths - cumulative total']
new24 = country_cumulative_df.at[country, 'Cases - newly reported in last 24 hours']
new7 = country_cumulative_df.at[country, 'Cases - newly reported in last 7 days']
fig3 = plt.figure(figsize=(8,8))
font = {'family': 'Arial',
'weight': 'bold',
'size' : 12
}
plt.rc('font', **font)
plt.rcParams.update({'text.color' : "black", 'axes.labelcolor' : "black"})
plt.pie([recovered, deaths, new24, new7],
labels = ['Recovered','Deaths','New cases - 24hrs', 'New cases - 7days'],
colors = ['lightgreen','red','pink','orange'],
explode = [0.2,0.02,0.2,0.1],
startangle = 180,
autopct = '%1.1f%%'
)
plt.title(country)
plt.legend()
plt.show()
else:
print("Please enter a valid country name!")